@extends('default.layouts.personalPublic')
@section('title', '账号设置')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/personal/setAccount.css')}}">
@endsection
@section('rightcon')
    <div class="right">
        <!--账号设置-->
        <div class="jright">
            <div class="content">
                <div class="jobtitle">
                    <div class="tithead">
                        <ul>
                            <li class="active"><a href="{{url('personal/set_account')}}">账号设置</a></li>
                            <li><a href="{{url('personal/mod_password')}}">修改密码</a></li>
                        </ul>
                    </div>
                </div>
                {{--账号设置主体内容--}}
                <div class="rightMain">
                    <div class="information">
                        <span>上次登录时间:</span>
                        <span class="ltime">2016-10-28 14:11:56</span>
                        <span class="changepass"><a href="{{url('personal/mod_password')}}">修改密码</a></span>
                    </div>
                    {{--多种绑定--}}
                    <div class="Binding">
                        <dl>
                            @if(empty($user->email_id))
                                <dt><i class="email"></i><span>登录邮箱</span></dt>
                                @if(empty($user->email))
                                    <dd class="binfo"><span>当前未填写邮箱绑定</span></dd>
                                @else
                                    <dd class="binfo"><span>当前登录邮箱未绑定：{{$user->stremail}}</span></dd>
                                @endif
                                <dd class="bindtype">
                                    <span><a onclick="bindEmail('{{$user->email}}')">立即绑定</a></span>
                                </dd>
                            @else
                                <dt><i class="bemail"></i><span>登录邮箱</span></dt>
                                <dd class="binfo"><span>当前邮箱已绑定：{{$user->stremail}}</span></dd>
                                <dd class="bindtype">
                                    <span><a onclick="bindEmail('')">修改</a></span>
                                </dd>
                            @endif
                        </dl>
                        <dl>
                            @if(empty($user->mobile_id))
                                <dt><i class="mobile"></i><span>更换手机</span></dt>
                                @if(empty($user->mobile))
                                    <dd class="binfo"><span>当前未填写手机绑定</span></dd>
                                @else
                                    <dd class="binfo"><span>当前登录手机未绑定：{{$user->strmobile}}</span></dd>
                                @endif
                                <dd class="bindtype">
                                    <span><a onclick="bindMobile('{{$user->mobile}}')">立即绑定</a></span>
                                </dd>
                            @else
                                <dt><i class="bmobile"></i><span>更换手机</span></dt>
                                <dd class="binfo"><span>当前手机已绑定：{{$user->strmobile}};</span></dd>
                                <dd class="bindtype">
                                    <span><a onclick="bindMobile('{{$user->mobile}}')">修改</a></span>
                                </dd>
                            @endif
                        </dl>

                        <dl>
                            @if(!empty($user->qqopenid))
                                <dt><i class="bqq"></i><span>绑定QQ</span></dt>
                                <dd class="binfo"><span>已绑定QQ号</span></dd>
                                <dd class="bindtype">
                                    <span><a onclick="cancelBind()">取消绑定</a></span>
                                </dd>
                            @else
                                @if(!empty(Site::get('personAppid')))
                                    <dt><i class="qq"></i><span>绑定QQ</span></dt>
                                    <dd class="binfo"><span>授权绑定后，可使用QQ号码快速登录</span></dd>
                                    <dd class="bindtype">
                                        <span><a href="{{url('personal/qqlogin')}}">立即绑定</a></span>
                                    </dd>
                                @else
                                    <dt><i class="bwechat"></i><span>绑定QQ</span></dt>
                                    <dd class="binfo"><span>你还没有开通QQ登录系统</span></dd>
                                @endif
                            @endif
                        </dl>


                        <dl>
                            @if(!empty($user->wechatopenid) || !empty($user->wechatmpopenid) || !empty($user->wechatunionid))
                                <dt><i class="bwechat"></i><span>绑定微信</span></dt>
                                <dd class="binfo"><span>已绑定微信号</span></dd>
                                <dd class="bindtype">
                                    <span><a onclick="cancel_wxbind()">取消绑定</a></span>
                                </dd>
                            @else
                                @if(!empty(Site::get('mpPersonOpenAppID')))
                                    <dt><i class="wechat"></i><span>绑定微信</span></dt>
                                    <dd class="binfo"><span>授权绑定后，可使用微信号码快速登录</span></dd>
                                    <dd class="bindtype">
                                        <span><a href="{{ weiXinlogin('personal') }}">立即绑定</a></span>
                                    </dd>
                                @elseif(!empty(Site::get('mpPersonAppID')))
                                    <dt><i class="wechat"></i><span>绑定微信</span></dt>
                                    <dd class="binfo"><span>授权绑定后，可使用微信号码快速登录</span></dd>
                                    <dd class="bindtype">
                                        <span><a onclick="bindwx()">立即绑定</a></span>
                                    </dd>
                                @else
                                    <dt><i class="bwechat"></i><span>绑定微信</span></dt>
                                    <dd class="binfo"><span>你还没有开通微信登录系统</span></dd>
                                @endif
                            @endif
                        </dl>

                    </div>
                </div>
                {{--//--}}
            </div>
        </div>
    </div>

@endsection
@section('footerjs')
    @parent
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.form.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.validate.extend.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/personal/bingAccounts.js')}}"></script>
    <script>
        $('#set').addClass('on').find('i').css('background-position', '-26px -114px');
        var imgCode = "{{captcha_src('code')}}" + Math.random();
        var _token = "{{csrf_token()}}";

        function cancelBind(){
            layer.confirm('您确定要取消QQ绑定吗？', {
                btn: ['确定', '取消'] //按钮
            }, function(){
                $.post("{{url('/personal/cancel_bind_qq')}}", {'_token': "{{csrf_token()}}"}, function(data){
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location = location;
                    }else{
                        layer.msg(data.msg, {icon: 5});
                    }
                });
            });
        }
        /**
         * QQ绑定
         */
        function cancel_wxbind(){
            layer.confirm('您确定要取消微信绑定吗？', {
                btn: ['确定', '取消'] //按钮
            }, function(){
                $.post("{{url('/personal/cancel_wxbind')}}", {'_token': "{{csrf_token()}}"}, function(data){
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location = '/personal/set_account';
                    }else{
                        layer.msg(data.msg, {icon: 5});
                    }
                });
            });
        }
        /**
         * 微信绑定
         */
        function bindwx(){
            layer.open({
                type: 1,
                title: '微信绑定',
                skin: 'layer-toshare',
                area: ['240px', '240px'],
                resize: false,
                move: false,
                btn: false,
                content: '<div class="ecode"><img src="{{asset('default/images/logo/code_weixin.png')}}"></div><div style="text-align: center">扫一扫微信绑定</div>'
            });
        }
    </script>
@endsection